/*
 * @Description: category迁移表
 * @Author: Junhuang
 * @Date: 2022-02-10 10:07:59
 * @LastEditTime: 2022-02-15 17:16:33
 * @LastEditors: Junhuang
 * @Reference: 
 */
'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { INTEGER, STRING, DATE, ENUM, TEXT } = Sequelize;
    // 创建表
    await queryInterface.createTable('category', {
      id: { type: INTEGER(20), primaryKey: true, autoIncrement: true, comment: '主键id' },
      title: { type: STRING(100), allowNull: false, defaultValue: '', comment: '分类名称', unique: true },
      cover: { type: STRING, allowNull: false, defaultValue: '', comment: '封面' },
      description: { type: TEXT, allowNull: false, defaultValue: '', comment: '描述' },
      created_time: DATE,
      updated_time: DATE
    });
  },

  async down(queryInterface, Sequelize) {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('category')
  }
};
